package socket;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class ClientSocket {
	
	private static ClientSocket clientSocket;
	
	public static ClientSocket getInstance() throws IOException {
		if (clientSocket == null) {
			clientSocket = new ClientSocket();
		}
		return clientSocket;
	}
	
	private static String host = "127.0.0.1";
	private static int port = 8081;
	
	public static void setHost(String host) {
		ClientSocket.host = host;
	}

	public static void setPort(int port) {
		ClientSocket.port = port;
	}

	private Socket socket;
	private OutputStream out;
	private InputStream in;
	
	private ClientSocket() throws IOException {
		socket = new Socket(host, port);
		out = socket.getOutputStream();
		in = socket.getInputStream();
	}

	public OutputStream getOutputStream(){
		return out;
	}
	
	public InputStream getInputStream(){
		return in;
	}

}
